home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 19 / CD_ASCQ_19_010295.iso / dos / prg / pas / swag / win_os2.swg / 0041_Windows Shell!.pas < prev    next >
Pascal/Delphi Source File  |  1994-08-25  |  2KB  |  80 lines

  1. {
  2. From: peter.gruhn@delta.com (Peter Gruhn)
  3.  
  4.  Ba> What I want to know is, can some-one post a sample of source code
  5.  Ba> that would provide a 'beginners shell' for windows programming. I.e.
  6.  
  7. How about if I post this test code that somebody wanted a few days ago.
  8. It has no interaction and doesn't bother to make use of the timer or
  9. anything in the draw loop, but it's a quick draw loop. You can set up
  10. timers and i/o responses as you see fit. Right off though, just having a
  11. window to draw in is a good start. It's how I started...
  12.  
  13. by Peter Gruhn
  14.  it's small and useless and stupid and somebody
  15.  might find it useful, so I release this program
  16.  into the public domain for the good of all
  17.  sentient species the universe over. 7-8-1994}
  18.  
  19. program offscree;
  20.  
  21. uses owindows,winprocs,wintypes;
  22.  
  23. type
  24.   TMyApp=object(tapplication)
  25.     procedure initmainwindow; virtual;
  26.     end;
  27.  
  28.   PMyWin=^TMyWin;
  29.   TMyWin=object(TWindow)
  30.     procedure Paint(PaintDC: HDC; var PaintInfo: TPaintStruct); virtual;
  31.     end;
  32.  
  33. procedure TMyApp.initmainwindow;
  34. begin
  35.   mainwindow:=new(pmywin,init(nil,'Try this...'));
  36. end;
  37.  
  38. procedure TMyWin.Paint;
  39. var adc:hdc;
  40.     abmp:hbitmap;
  41.     i:integer;
  42.     s:string;
  43. begin
  44. {Create stuff}
  45.   adc:=createcompatibledc(paintdc);
  46.   {I believe that I am cheating here, by just divving number of bits
  47.    by 2 as I happen to know that right now I am in 16 colour mode.
  48.    You will forgive me.}
  49.   abmp:=createcompatiblebitmap(paintdc,300 div 2,300 div 2);
  50.   abmp:=selectobject(adc,abmp);
  51.  
  52. {Blank off screen bitmap of random data}
  53.   bitblt(adc,0,0,300,300,adc,0,0,whiteness);
  54.  
  55. {Draw something}
  56.   for i:=0 to 1024 do
  57.     begin
  58.     rectangle(adc,random(300),random(300),random(300),random(300));
  59.     str(i:5,s);                    {textify i for...}
  60.     s[6]:=#0;                      {null terminator}
  61.     textout(paintdc,10,10,@(s[1]),byte(s[0])); {just to count so it don't look
  62. plain}
  63.     end;
  64.  
  65. {blit it to the window}
  66.   bitblt(paintdc,10,10,300,300,adc,0,0,srccopy);
  67.  
  68. {Kill stuff}
  69.   deleteobject(selectobject(adc,abmp));
  70.   deletedc(adc);
  71. end;
  72.  
  73. var app:TMyApp;
  74.  
  75. begin
  76.   app.init('frog');
  77.   app.run;
  78.   app.done;
  79. end.
  80.